package com.code.leetcode.offer;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/13 17:56
 */
public class The63 {
    public int maxProfit(int[] prices) {
        int sum = 0;
        if (prices == null || prices.length == 0) return sum;
        int min = prices[0];
        for (int i = 1; i < prices.length; i++) {
            if (prices[i] < min) min = prices[i];
            sum = Math.max(sum, prices[i] - min);
        }
        return sum;
    }
}
